package xixirupan.tmgp.tencent.com.vmeim.ui.beautyshop.presenter;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;

import java.util.ArrayList;
import java.util.List;

import xixirupan.tmgp.tencent.com.vmeim.config.URLConfig;
import xixirupan.tmgp.tencent.com.vmeim.ui.beautyshop.model.TopBannersBaen;

/**
 * Created by lenovo on 2016/10/19.
 */

public class ViewPagerAdapter extends PagerAdapter{
    List<TopBannersBaen>   lists;
    List<ImageView> lists_img;
    Context context;
      public ViewPagerAdapter(Context context,  List<TopBannersBaen>  lists)
      {
          this.context =context;
          this.lists =lists;
          lists_img =new ArrayList<>();
          for (int i = 0; i < lists.size(); i++) {
              ImageView img =new ImageView(context);
              String url = URLConfig.Url.BASE_URL+lists.get(i).getImgURL();

              Glide.with(context).load(url).into(img);
              lists_img.add(img);
          }

      }
    @Override
    public int getCount() {
        return lists_img.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(lists_img.get(position));
        return lists_img.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {

        container.removeView(lists_img.get(position));
    }

    @Override
    public void destroyItem(View container, int position, Object object) {
        super.destroyItem(container, position, object);

    }
}
